//

// (  )
//

package com.tools.acceleratecore;

import android.content.Context;

import com.dianxinos.acceleratecore.logic.clean.impl.CleanDirFileInfo;
import com.dianxinos.acceleratecore.logic.clean.impl.CleanEnumDirFile;
import com.dianxinos.acceleratecore.logic.clean.impl.CleanMgr;
import com.dianxinos.acceleratecore.logic.clean.intf.ICleanDirFileInfo;
import com.dianxinos.acceleratecore.logic.clean.intf.ICleanEnumDirFile;
import com.dianxinos.acceleratecore.xlib.xlib.intf.IXObject;
import com.tools.acceleratecore.logic.accelerate.memorydeepoptimizer.impl.MemoryAnalyzer;
import com.tools.acceleratecore.logic.accelerate.memorydeepoptimizer.impl.MemoryDeepOptimizer;
import com.tools.acceleratecore.logic.accelerate.memorydeepoptimizer.impl.MemoryDeepOptimizerMgr;
import com.tools.acceleratecore.logic.accelerate.memorydeepoptimizer.intf.IMemoryAnalyzer;
import com.tools.acceleratecore.logic.accelerate.memorydeepoptimizer.intf.IMemoryDeepOptimizer;
import com.tools.acceleratecore.logic.accelerate.memorydeepoptimizer.intf.IMemoryDeepOptimizerMgr;
import com.tools.acceleratecore.logic.accelerate.process.impl.ProcessItem;
import com.tools.acceleratecore.logic.accelerate.process.impl.ProcessKillerNormal;
import com.tools.acceleratecore.logic.accelerate.process.impl.ProcessKillerRoot;
import com.tools.acceleratecore.logic.accelerate.process.impl.ProcessMgr;
import com.tools.acceleratecore.logic.accelerate.process.intf.IProcessItem;
import com.tools.acceleratecore.logic.accelerate.process.intf.IProcessKiller;
import com.tools.acceleratecore.logic.accelerate.process.intf.IProcessMgr;
import com.tools.acceleratecore.logic.accelerate.temperature.impl.TemperatureMgr;
import com.tools.acceleratecore.logic.accelerate.temperature.intf.ITemperatureMgr;
import com.tools.acceleratecore.logic.clean.intf.ICleanMgr;
import com.tools.acceleratecore.logic.common.impl.AppItem;
import com.tools.acceleratecore.logic.common.intf.IAppItem;
import com.tools.acceleratecore.tool.impl.NativeMgr;
import com.tools.acceleratecore.tool.intf.INativeMgr;
import com.tools.acceleratecore.util.UtilInstaller;
import com.tools.acceleratecore.xlib.XLibFactory;
import com.tools.acceleratecore.xlib.xlib.impl.XFactory;
import com.tools.acceleratecore.xlib.xlib.intf.IXFactory;

import java.util.HashMap;

public class AccelerateCoreFactory extends XFactory {
    private static IXFactory sIXFactory = null;
    private static Context sContext = null;
    private static int sLoadLib = 0;

    public AccelerateCoreFactory() {
        this.xFactoryInterfaceMap = new HashMap();
        this.xFactoryInterfaceMap.put(ITemperatureMgr.class, new XFactoryImplementMap(new Class[]{TemperatureMgr.class}, new IXObject[1]));
        this.xFactoryInterfaceMap.put(IMemoryDeepOptimizerMgr.class, new XFactoryImplementMap(new Class[]{MemoryDeepOptimizerMgr.class}, new IXObject[1]));
        this.xFactoryInterfaceMap.put(IMemoryDeepOptimizer.class, new XFactoryImplementMap(new Class[]{MemoryDeepOptimizer.class}, new IXObject[1]));
        this.xFactoryInterfaceMap.put(IMemoryAnalyzer.class, new XFactoryImplementMap(new Class[]{MemoryAnalyzer.class}, new IXObject[1]));
        this.xFactoryInterfaceMap.put(INativeMgr.class, new XFactoryImplementMap(new Class[]{NativeMgr.class}, new IXObject[1]));
        this.xFactoryInterfaceMap.put(ICleanMgr.class, new XFactoryImplementMap(new Class[]{CleanMgr.class}, new IXObject[1]));
        this.xFactoryInterfaceMap.put(ICleanDirFileInfo.class, new XFactoryImplementMap(new Class[]{CleanDirFileInfo.class}, new IXObject[1]));
        this.xFactoryInterfaceMap.put(ICleanEnumDirFile.class, new XFactoryImplementMap(new Class[]{CleanEnumDirFile.class}, new IXObject[1]));
        this.xFactoryInterfaceMap.put(IProcessMgr.class, new XFactoryImplementMap(new Class[]{ProcessMgr.class}, new IXObject[1]));
        this.xFactoryInterfaceMap.put(IProcessItem.class, new XFactoryImplementMap(new Class[]{ProcessItem.class}, new IXObject[1]));
        this.xFactoryInterfaceMap.put(IProcessKiller.class, new XFactoryImplementMap(new Class[]{ProcessKillerNormal.class, ProcessKillerRoot.class}, new IXObject[2]));
        this.xFactoryInterfaceMap.put(IAppItem.class, new XFactoryImplementMap(new Class[]{AppItem.class}, new IXObject[1]));
    }

    public static boolean isLoadLib() {
        return sLoadLib != CleanCoreConstant.LOAD_LIB_FAILED;
    }

    public static int getLoadLib() {
        return sLoadLib;
    }

    public static IXFactory getInstance() {
        if (sIXFactory == null) {
            Class var0 = AccelerateCoreFactory.class;
            synchronized (AccelerateCoreFactory.class) {
                if (sIXFactory == null) {
                    sIXFactory = new AccelerateCoreFactory();
                }
            }
        }

        return sIXFactory;
    }

    public static void setApplication(Context context) {
        sContext = context;
        XLibFactory.setApplication(context);
        sLoadLib = UtilInstaller.loadLibrary(context);
    }

    public static Context getApplication() {
        return sContext;
    }
}
